package preadd.p1;

public class test1732 {
    public static void main(String[] args) {
        int nums[] = {44,32,-9,52,23,-50,50,33,-84,47,-14,84,36,-62,37,81,-36,-85,-39,67,-63,64,-47,95,91,-40,65,67,92,-28,97,100,81};
        Solution solution = new Solution();
        int max = solution.largestAltitude(nums);
        System.out.println(max);
    }
}

class Solution {
    public int largestAltitude(int[] gain) {
        int max=0;
        int al=gain[0];
        if(al>max){
            max=al;
        }
        for(int i=1;i<gain.length;i++){
            al+=gain[i];
            if(al>max){
                max=al;
            }

        }

        return max;
    }
}